
// 封装统一返回对象

export class Result<T> {
    private data: T;
    private msg: string;
    private code: number;

    public constructor(status: number, message: string, data: T) {
        this.data = data;
        this.code = status;
        this.msg = message;
    }

    public static ok<T>(data: T, message: string='success'): any {
        return new Result(2000, message, data)
    }

    public static fail<T>(message: string='fail'): any {
        return new Result(1999, message, null)
    }
}